<template>
  <div class="common-layout">
    <el-container>
      <el-header>
        <div class="logo">
          <img src="../assets/moon.jpg">
          <h1>xxxx后台管理系统</h1>
        </div>
        <el-button class="btnLogout" type="primary" @click="logoutFun" round>注销</el-button>
      </el-header>
      <el-container>
        <el-aside>
          <el-menu
              active-text-color="#ffd04b"
              background-color="#545c64"
              class="el-menu-vertical-demo"
              default-active="2"
              text-color="#fff"
              :router="true"
              :default-active="activePath"
              @open="handleOpen"
              @close="handleClose"
          >
            <el-sub-menu index="1">
              <template #title>
                <el-icon>
                  <location/>
                </el-icon>
                <span>用户管理</span>
              </template>
              <el-menu-item index="/userList">用户列表</el-menu-item>
              <el-menu-item index="1-2">用户添加</el-menu-item>
            </el-sub-menu>
            <el-sub-menu index="2">
              <template #title>
                <el-icon>
                  <location/>
                </el-icon>
                <span>角色管理</span>
              </template>
              <el-menu-item index="2-1">角色列表</el-menu-item>
              <el-menu-item index="2-2">角色添加</el-menu-item>
            </el-sub-menu>
            <el-sub-menu index="3">
              <template #title>
                <el-icon>
                  <location/>
                </el-icon>
                <span>权限管理</span>
              </template>
              <el-menu-item index="3-1">权限列表</el-menu-item>
              <el-menu-item index="3-2">权限添加</el-menu-item>
            </el-sub-menu>
          </el-menu>
        </el-aside>
        <el-main>
          <router-view></router-view>
        </el-main>
      </el-container>
    </el-container>
  </div>
</template>
<script>
export default {
  name: 'Index'
  , data(){
    return {
      activePath: '/index'
    }
  }
  , methods: {
    handleOpen() {
    }
    , handleClose() {
    }
    ,logoutFun(){
      if(confirm('确认注销当前用户吗?')){
        sessionStorage.removeItem('token');
        location.href = '/login'
      }
    }
  }
}
</script>
<style scoped>
.common-layout, el-container {
  height: 100%;
}

.el-header {
  background-color: #545C64;
  height: 10%;
  display: flex;
  justify-content: space-between;
}
.btnLogout{
  margin: 20px;
}
.logo{
  display: flex;
}

.logo > img {
  width: 60px;
  height: 50px;
  margin: 20px;
}

.logo > h1 {
  margin-top: 20px;
  color: white;
}

.el-aside {
  height: 100%;
  width: 10%;
}

</style>